import Vue from 'vue'
import Router from 'vue-router'
import axios from 'axios'
import { request } from "../assets/js/utils/request"

Vue.use(Router);
const router = new Router({
    mode:"hash",//1、hash哈希：有#号。2、history历史：没有#号
    base:process.env.BASE_URL, //自动获取根目录路径
    scrollBehavior:(to,from,position)=>{
        if(position){
            return position
        }else{
            return {x:0,y:0}
        }
    },
    routes:[
        {
            path: '/',
            name: 'index',
            component: () => import('../view/pageIndex.vue')
        }
    ]
})
// router.beforeEach((to,from,next) => {
//     const token = sessionStorage.getItem('token')
//     const loginTime = sessionStorage.getItem("loginTime");
//     if(to.path == '/login' || to.path == '/loginSuccessful') {
//         next()
//     } else {
//         if(!token) {
//             next('/login')
//         } else {
//             next()
//         }
//     }
//     if(token && to.path == '/') {
//         next('/')
//     }
// })
export default router